import axios from "@/http/axios";
// import type { StudentInfoConfigProps } from "@/http/Api/type";

interface StudentConfigProps {
  id?: number | string; // 学生用户账户主键id,添加学员时会自动生成,修改时需要赋值
  headPortrait: string; // 头像
  nickname: string;
  phone: string;
  sex: string;
  baiJieClassId: number | string; // 百杰班级外键id
  username: string;
}

interface QueryStudentConfigProps {
  baiJieClassId: number | string; // 百杰班级外键id
  number: number; // 页数
  phone: string; // 电话
  size: number; // 每页条数
  username: string; // 用户名
}

interface UpdateStudentClassIdProps {
  baiJieClassId: number | string;
  phoneArr: Array<string>;
}

// 添加或者修改学员信息
export const modifyStudentApi = (params: StudentConfigProps) =>
  axios({
    url: "/exam/accountMessage/modify",
    method: "POST",
    params,
  });

// 根据条件查询学员
export const queryStudentApi = (params: QueryStudentConfigProps) =>
  axios({
    url: "/exam/accountMessage/query",
    method: "GET",
    params,
  });

// 查看当前学员信息
export const getStudentInfoApi = (phone: string) =>
  axios({
    url: "/exam/accountMessage/get",
    method: "POST",
    params: {
      phone,
    },
  });

// 判断手机号在系统中是否存在,1 表示存在,0 表示不存在
export const checkStudentPhoneApi = (phone: string) =>
  axios({
    url: "/exam/accountMessage/getByPhone",
    method: "POST",
    params: {
      phone,
    },
  });

// 批量修改学生信息班级编号
export const updateStudentClassIdApi = (params: UpdateStudentClassIdProps) =>
  axios({
    url: "/exam/accountMessage/updateClassId",
    method: "POST",
    params,
  });

// 删除学员
export const delStudentApi = (phone: string) =>
  axios({
    url: "/exam/accountMessage/del",
    method: "POST",
    params: {
      phone,
    },
  });

// 批量删除学员
export const delStudentByMoreApi = (phoneArr: Array<string>) =>
  axios({
    url: "/exam/accountMessage/delBatch",
    method: "POST",
    params: {
      phoneArr,
    },
  });

// 批量上传学生信息
// 注意:1.班级一定是现有班级2.手机号必须正确必须是字符3.密码默认为手机后六位4.昵称默认姓氏
// export const uploadExcelStudentApi = (file: string) =>
//   axios({
//     url: "/exam/accountMessage/uploadExcel",
//     method: "POST",
//     params: {
//       file,
//     },
//   });
export const uploadExcelStudentURI =
  window.BASE_API + "/exam/accountMessage/uploadExcel";
